package com.qianniu.napi.common.config;

import com.google.common.base.Strings;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.ResourceBundle;

public class ConfigUtil {

    private static ResourceBundle bundle;
    private static final Logger logger = LoggerFactory.getLogger(ConfigUtil.class);

    static {
        try {
            bundle = ResourceBundle.getBundle("application");
        } catch (Exception e) {
            logger.error("get resource file fail:" + e.getMessage());
        }
    }

    public static String getString(String key) {
        if (Strings.isNullOrEmpty(key)) {
            logger.error("param is empty");
            return null;
        }
        try {
            return bundle.getString(key);
        } catch (java.util.MissingResourceException e) {
            logger.error("get resource key fail:" + e.getMessage());
        }
        return null;
    }
}
